<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业物联网转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\common\model\approval;

use app\common\model\BaseModel;
use app\common\model\users\UsersModel;
use app\common\model\work\WorkReportModel;

class ApprovalReceivesModel extends BaseModel
{
    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'add_time';
    protected $updateTime = false;

    public static function tablePk(): string
    {
        return 'id';
    }

    public static function tableName(): string
    {
        return 'approval_receives';
    }

    public function submitUserInfo()
    {
        return $this->hasOne(UsersModel::class, 'id', 'submit_uid');
    }

    public function presentUserInfo()
    {
        return $this->hasOne(UsersModel::class, 'id', 'present_uid');
    }


    public function getSourceInfoAttr()
    {
        $data = [];
        if ($this->is_type == 1) {
            ##工作汇报
            $data = WorkReportModel::where('id', $this->source_id)->field('report_name,remark')->find();
        }

        return $data;
    }

}
